#ifndef FIREBOT_H
#define FIREBOT_H

#include <stdio.h>
#include <time.h>

#include "Mstructs.h"

#include "commands.h"

#include "TS7260IO.h"
//#include "I2C.h"
#include "RS232.h"

#include "socket.h"

extern bool verbose_log; //verbose log of process() loops

class CFirebot
{
      public:
       
       TS7260IO fbIO; //TS7260 IO wrapper
       CSocket fbSock;//*nix style socket wrapper
       //I2C *fbI2C;
       RS232 *fbCOM2;
      
       RS232_PACKET kill_pkt;
       
       
       
       CFirebot();
       ~CFirebot();
       
       void process();
       void parse_command(unsigned char *buffer, int len); //parses commands received stored in a buffer(intended for sockets)  
       
       //socket related
       void sock_sendAllIO();
       void sock_sendpacket(unsigned char command, unsigned char *buffer, int len); //appends command to buffer of size len, 
       void sock_sendcommand(unsigned char command); //appends command to buffer of size len, 

       
    //   bool checkTicks(clock_t dt); //returns true when successive calls of this function give clock tick are >= dt   
      private:
              bool timeout_flag; //used as a timeout flag if connection to the host computer is lost
              void EVENT_KILL();
              
             // bool sample;
             // clock_t prev;
      bool timeout_period; //= 0; //timeout flag for ping acknowledgement from host computer  
      int timeoutc;
      bool sample;// = 1;
      
      clock_t prev, dude;
      struct timeval wtf;

              
};

  
#endif
